from flask import Flask
from flask_cors import CORS
from app.config.config import config
from app.api.routes import api

def create_app(config_name='default'):
    """
    Application factory function
    
    Args:
        config_name: Configuration name to use
        
    Returns:
        Flask application instance
    """
    app = Flask(__name__)
    
    # Load configuration
    app.config.from_object(config[config_name])
    
    # Initialize extensions
    CORS(app)
    
    # Register blueprints
    app.register_blueprint(api, url_prefix='/api')
    
    return app 